package com.cdel.akka.AkkainJAVA.demo1;

import akka.actor.UntypedActor;

/**
 * 打招呼的Actor
 *
 * @author SUN
 * @version 1.0
 * @Date 16/1/6 21:40
 */
public class GreeterActor extends UntypedActor {
	String greeting = "";

	@Override
	public void onReceive(Object message) throws Exception {
		if (message instanceof WhoToGreet)
			greeting = "hello, " + ((WhoToGreet) message).who;
		else if (message instanceof Greet)
			// 发送招呼消息给发送消息给这个Actor的Actor
			getSender().tell(new Greeting(greeting), getSelf());
		else
			unhandled(message);
	}

}